﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chat_D_LuX_Client.Controls
{
    /// <summary>
    /// Interaction logic for ucMessage.xaml
    /// </summary>
    public partial class ucMessage : UserControl
    {        
        private bool _isAltColor = false;
        public bool IsAltColor 
        { 
            get 
            {
                return _isAltColor;
            } 
            set
            {                
                if (value)
                {
                    this.Background = new SolidColorBrush(Color.FromArgb(100, 212, 212, 212));
                }
                else
                {
                    this.Background = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
                }
                _isAltColor = value;
            }
        }        
        public string MessageText
        {
            get 
            {
                return txtMessage.Text;
            }
            set
            {                
                txtMessage.Text = value;
            }
        }

        public string User
        {
            get
            {
                return txtUsername.Text;
            }
            set
            {
                txtUsername.Text = value;
            }
        }

        public string Timestamp
        {
            get
            {
                return lblTime.Content.ToString();
            }
            set
            {
                lblTime.Content = value;
            }
        }

        public ucMessage()
        {
            InitializeComponent();
        }

        private void txtMessage_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (txtMessage.ActualHeight > 48)
            {
                //This should reset the control to the maximum height without overflowing visually
                this.Height = 70 + (txtMessage.ActualHeight - 43);
            }
            else 
            {
                this.Height = 70;
            }
        }
    }
}
